#!/bin/sh

echo Try to bring wlan0 interface up......>/dev/ttySAC2

#support MT6620 WIFI Module  
  mknod /dev/stpwmt c 190 0
  mknod /dev/stpgps c 191 0
  mknod /dev/fm c 193 0
  mknod /dev/wmtWifi c 194 0

  insmod /lib/modules/mt6620/mtk_hif_sdio.ko
  insmod /lib/modules/mt6620/mtk_stp_wmt.ko
  insmod /lib/modules/mt6620/mtk_stp_uart.ko
  insmod /lib/modules/mt6620/mtk_stp_gps.ko
  #insmod /lib/modules/mt6620/hci_stp.ko
  insmod /lib/modules/mt6620/mt6620_fm_drv.ko
  insmod /lib/modules/mt6620/mtk_fm_priv.ko
  insmod /lib/modules/mt6620/mtk_wmt_wifi.ko WIFI_major=194
  insmod /lib/modules/mt6620/wlan.ko

  chmod 0666 /dev/stpwmt
  chmod 0666 /dev/stpgps
  chmod 0666 /dev/fm
  chmod 0666 /dev/wmtWifi
  chmod 0660 /dev/ttySAC0
  chmod 0666 /dev/gps

  /usr/bin/6620_launcher -m 1 -b 921600 -n /etc/firmware/mt6620_patch_hdr.bin -d /dev/ttySAC0 &

  sleep 1
  
  echo 1 > /dev/wmtWifi
  
#  wpa_supplicant -d -Dwext -iwlan0 -c /etc/wpa_supplicant.conf &
#  dhclient wlan0 &

  ifconfig eth0 down
  
  sleep 2

  wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant.conf -dd >/var/wifi_log &

  sleep 15
  udhcpc -i wlan0 >/var/udhcpc_log &
